package com.dwxt.cdms.controller;

import com.dwxt.cdms.entity.Blutdruck;
import com.dwxt.cdms.entity.vo.BlutdruckCustom;
import com.dwxt.cdms.service.AiAoLeDataService;
import com.dwxt.common.base.BaseResult;
import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 解析爱奥乐设备数据
 *
 * @author Kuang.JiaZhuo
 * @date 2020-09-03 16:10
 */
@RestController
@RequestMapping("/cdms/parse")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class AiAoLeDataController {

    private final AiAoLeDataService aiAoLeDataService;

    /**
     * @方法名：getBloodPressureAndBloodSugar
     * @描述： 解析(并新增)血压或血糖数据返回json
     * @作者： kjz
     * @日期： Created in 2020/9/3 16:45
     */
//    @GetMapping("getBloodPressureAndBloodSugar")
//    public BaseResult getBloodPressureAndBloodSugar(HttpServletRequest request, HttpServletResponse response, @RequestParam("data") String data) {
//        return BaseResult.ok(aiAoLeDataService.getBloodPressureAndBloodSugarBest(request,response,data));
//    }

    @GetMapping("getBloodPressureAndBloodSugarBest")
    public String getBloodPressureAndBloodSugarBest(HttpServletRequest request, HttpServletResponse response, @RequestParam("data") String data) {
        return aiAoLeDataService.getBloodPressureAndBloodSugarBest(request,response,data);
    }

    /**
     * @方法名：selectBloodPressureByCondition
     * @描述： 按条件(带分页)查询血压列表
     * @作者： kjz
     * @日期： Created in 2020/9/4 11:02
     */
    @RequestMapping("selectBloodPressureByCondition")
    public BaseResult selectBloodPressureByCondition(Integer pageNum, Integer pageSize) {
        PageInfo<Blutdruck> pageInfo = aiAoLeDataService.selectBloodPressureByCondition(pageNum,pageSize);
        return BaseResult.ok(pageInfo);
    }

    /**
     * @方法名：selectBloodPressureById
     * @描述： 根据id查询血压数据详情
     * @作者： kjz
     * @日期： Created in 2020/9/4 11:23
     */
    @RequestMapping("selectBloodPressureById")
    public BaseResult selectBloodPressureById(@RequestParam("id") String id) {
        Blutdruck blutdruck = aiAoLeDataService.selectBloodPressureById(id);
        return BaseResult.ok(blutdruck);
    }

    /**
     * @Description:
     * @param customerId: 客户id
     * @param scope:   时间范围
     * @return com.dwxt.common.base.BaseResult
     * @author chendq
     * @date 2021/8/19
     */
    @RequestMapping("selectCustomerBloodPressureList")
    public BaseResult selectCustomerBloodPressureList(@RequestParam(required = true) String customerId,
                                              @RequestParam(required = true,defaultValue = "1")Integer scope,
                                              @RequestParam(required = true,defaultValue = "0")Integer partId) {
        return BaseResult.ok(aiAoLeDataService.selectBloodPressureList(customerId,scope,partId));
    }
}
